Fix GPU Memory Leak in GLTF Geometry Import #792
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Bug
File:
packages/phoenix-event-display/src/managers/three-manager/import-manager.tsFunction:
ImportManager.loadGLTFGeometryInternal(Lines 409-445)When loading GLTF geometries, cloned geometries are collected in
materials[key].geomsarrays, merged into a final geometry, but intermediate geometries are never disposed. This leaves orphaned WebGL buffers in GPU memory.Identical pattern to the leak fixed in
phoenix-objects.ts(commit ad79b44) but missed in import-manager.ts.The Fix
Summary: After
BufferGeometryUtils.mergeGeometries(), added disposal loop for all intermediate geometries in thematerialsobject.Files changed: 1 (
import-manager.ts)Validation: All 166 tests pass + linting clean
Why This Matters
How to Verify
See
import-manager.tsdiff in this PR. To test locally:chrome://gpuAfter: Memory stays stable after each load
Impact
Eliminates crashes during long-running detector visualization sessions. Matches our existing cleanup pattern from
phoenix-objects.ts. Zero render behavior change—just proper Three.js resource management.